package com.enbatis.mybatisplugs.controller;
import com.enbatis.mybatisplugs.base.BaseController;
import com.enbatis.mybatisplugs.commons.sql.Wrapper;
import com.enbatis.mybatisplugs.commons.utils.ResultReturn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.enbatis.mybatisplugs.entity.SysMsg;
import com.enbatis.mybatisplugs.service.SysMsgService;
import java.util.List;

@RestController
@RequestMapping("v1/sys_msg")
public class SysMsgController extends BaseController {

@Autowired
private SysMsgService sysMsgService;



    @PostMapping("/add")
    public ResultReturn<SysMsg> add(@RequestBody SysMsg sysMsg){
        return  success(sysMsgService.insert(sysMsg));
    }


    @DeleteMapping("/delete")
    public ResultReturn<Integer> delete(@RequestParam("id") Long id){
        return success(sysMsgService.deleteById(id));
    }


    @PutMapping("/{id}")
    public  ResultReturn<Integer> update(@PathVariable("id") Long id,@RequestBody SysMsg sysMsg){
        sysMsg.setId(id);
        return success(sysMsgService.updateById(sysMsg));
    }


    @GetMapping("/{id}")
    public ResultReturn<SysMsg> get(@PathVariable("id") Long id) {
        return success(sysMsgService.getById(id));
    }


    @GetMapping("/list")
    public ResultReturn<List<SysMsg>> getList(SysMsg sysMsg){
        return success(sysMsgService.list(new Wrapper<>(sysMsg)));
    }

}
